home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_xemacs.idb / usr / freeware / lib / xemacs-20.4 / info / cc-mode.info-2.z / cc-mode.info-2
Encoding:
GNU Info File  |  1998-05-21  |  48.7 KB  |  1,244 lines

  1. This is Info file ../info/cc-mode.info, produced by Makeinfo version
  2. 1.68 from the input file cc-mode.texi.
  3.  
  4.    Copyright (C) 1995, 1996 Free Software Foundation, Inc.
  5.  
  6. 
  7. File: cc-mode.info,  Node: Built-in Styles,  Next: Adding Styles,  Up: Styles
  8.  
  9. Built-in Styles
  10. ---------------
  11.  
  12.    If you're lucky, one of CC Mode's built-in styles might be just what
  13. you're looking for.  These include:
  14.  
  15.    * `gnu' -- coding style blessed by the Free Software Foundation for
  16.      C code in GNU programs.
  17.  
  18.    * `k&r' -- The classic Kernighan and Ritchie style for C code.
  19.  
  20.    * `bsd' -- Also known as "Allman style" after Eric Allman.
  21.  
  22.    * `whitesmith' -- Popularized by the examples that came with
  23.      Whitesmiths C, an early commercial C compiler.
  24.  
  25.    * `stroustrup' -- The classic Stroustrup style for C++ code.
  26.  
  27.    * `ellemtel' -- Popular C++ coding standards as defined by
  28.      "Programming in C++, Rules and Recommendations", Erik Nyquist and
  29.      Mats Henricson, Ellemtel (1).
  30.  
  31.    * `linux' -- C coding standard for Linux development.
  32.  
  33.    * `python' -- C coding standard for Python extension modules(2).
  34.  
  35.    * `java' -- The style for editing Java code.  Note that this style is
  36.      automatically installed when you enter `java-mode'.
  37.  
  38.    If you'd like to experiment with these built-in styles you can simply
  39. type the following in a CC Mode buffer:
  40.  
  41.      C-c . STYLE-NAME RET
  42.  
  43. `C-c .' runs the command `c-set-style'.  Note that all style names are
  44. case insensitive, even the ones you define.
  45.  
  46.    Setting a style in this way does *not* automatically re-indent your
  47. file.  For commands that you can use to view the effect of your changes,
  48. see *Note Commands::.
  49.  
  50.    Once you find a built-in style you like, you can make the change
  51. permanent by adding some lisp to your `.emacs' file.  Let's say for
  52. example that you want to use the `ellemtel' style in all your files.
  53. You would add this:
  54.  
  55.      (defun my-c-mode-common-hook ()
  56.        ;; use Ellemtel style for all C like languages
  57.        (c-set-style "ellemtel")
  58.        ;; other customizations can go here
  59.        )
  60.      (add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
  61.  
  62.    There is one other special style you can use, called `cc-mode'
  63. style.  This style is special because all other styles implicitly
  64. inherit from it; in other words, whenever you set a style, `cc-mode' is
  65. applied before the one you selected.  This means your style need only
  66. define the differences between it and `cc-mode' style.
  67.  
  68.    Note *you should never change any of the default styles*.  Instead,
  69. it's better to add a new style using `c-add-style' (*Note Adding
  70. Styles::).  This is especially true for `cc-mode' and `java' styles.
  71.  
  72.    Note that for BOCM compatibility, `gnu' is the default style, and
  73. any non-style based customizations you make (i.e. in
  74. `c-mode-common-hook' in your `.emacs' file) will be based on `gnu'
  75. style unless you do a `c-set-style' as the first thing in your hook.
  76. The variable `c-indentation-style' always contains the buffer's current
  77. style name, as a string.
  78.  
  79.    ---------- Footnotes ----------
  80.  
  81.    (1) This document is ftp'able from `euagate.eua.ericsson.se'
  82.  
  83.    (2) Python is a high level scripting language with a C/C++ foreign
  84. function interface.  For more information, see
  85. `<http://www.python.org/>'.
  86.  
  87. 
  88. File: cc-mode.info,  Node: Adding Styles,  Next: File Styles,  Prev: Built-in Styles,  Up: Styles
  89.  
  90. Adding Styles
  91. -------------
  92.  
  93.    If none of the built-in styles is appropriate, you'll probably want
  94. to add a new "style definition".  Styles are kept in the
  95. `c-style-alist' variable, but you should never modify this variable
  96. directly.  Instead, CC Mode provides the function `c-add-style' that
  97. you can use to easily add new styles or change existing styles.  This
  98. function takes two arguments, a STYLENAME string, and an association
  99. list DESCRIPTION of style customizations.  If STYLENAME is not already
  100. in `c-style-alist', the new style is added, otherwise the style is
  101. changed to the new DESCRIPTION.  This function also takes an optional
  102. third argument, which if non-`nil', automatically applies the new style
  103. to the current buffer.
  104.  
  105.    The sample `.emacs' file provides a concrete example of how a new
  106. style can be added and automatically set.  *Note Sample .emacs File::.
  107.  
  108. 
  109. File: cc-mode.info,  Node: File Styles,  Prev: Adding Styles,  Up: Styles
  110.  
  111. File Styles
  112. -----------
  113.  
  114.    The Emacs manual describes how you can customize certain variables
  115. on a per-file basis by including a "Local Variable" block at the end of
  116. the file.  So far, you've only seen a functional interface to CC Mode
  117. customization, which is highly inconvenient for use in a Local Variable
  118. block.  CC Mode provides two variables that make it easier for you to
  119. customize your style on a per-file basis(1)
  120.  
  121.    The variable `c-file-style' can be set to a style name string.  When
  122. the file is visited, CC Mode will automatically set the file's style to
  123. this style using `c-set-style'.
  124.  
  125.    Another variable, `c-file-offsets', takes an association list
  126. similar to what is allowed in `c-offsets-alist'.  When the file is
  127. visited, CC Mode will automatically institute these offets using
  128. `c-set-offset'.
  129.  
  130.    Note that file style settings (i.e. `c-file-style') are applied
  131. before file offset settings (i.e. `c-file-offsets').
  132.  
  133.    ---------- Footnotes ----------
  134.  
  135.    (1) Note that this feature doesn't work with Emacs versions before
  136. XEmacs 19.12 and Emacs 19.29.  It works via the standard Emacs hook
  137. variable `hack-local-variables-hook'.
  138.  
  139. 
  140. File: cc-mode.info,  Node: Advanced Customizations,  Prev: Styles,  Up: Customizing Indentation
  141.  
  142. Advanced Customizations
  143. =======================
  144.  
  145.    For most users, CC Mode will support their coding styles with very
  146. little need for more advanced customizations.  Usually, one of the
  147. standard styles defined in `c-style-alist' will do the trick.  At most,
  148. perhaps one of the syntactic symbol offsets will need to be tweaked
  149. slightly, or maybe `c-basic-offset' will need to be changed.  However,
  150. some styles require a more flexible framework for customization, and
  151. one of the real strengths of CC Mode is that the syntactic analysis
  152. model provides just such a framework. This allows you to implement
  153. custom indentation calculations for situations not handled by the mode
  154. directly.
  155.  
  156.    Note that the style controlling variables can either have global
  157. values, or can be buffer local (e.g. different in every buffer).  If
  158. all the C files you edit tend to have the same style, you might want to
  159. keep the variables global.  If you tend to edit files with many
  160. different styles, you will have to make the variables buffer local.
  161. The variable `c-style-variables-are-local-p' controls this.
  162.  
  163.    When `c-style-variables-are-local-p' is non-nil, then the style
  164. variables will have a different settable value for each buffer,
  165. otherwise all buffers will share the same values.  By default, its value
  166. is `nil' (i.e. global values).  You *must* set this variable before CC
  167. Mode is loaded into your Emacs session, and once the variables are made
  168. buffer local, they cannot be made global again (unless you restart
  169. Emacs of course!)
  170.  
  171. * Menu:
  172.  
  173. * Custom Indentation Functions::
  174. * Custom Brace and Colon Hanging::
  175. * Customizing Semi-colons and Commas::
  176. * Other Special Indentations::
  177.  
  178. 
  179. File: cc-mode.info,  Node: Custom Indentation Functions,  Next: Custom Brace and Colon Hanging,  Up: Advanced Customizations
  180.  
  181. Custom Indentation Functions
  182. ----------------------------
  183.  
  184.    The most flexible way to customize CC Mode is by writing "custom
  185. indentation functions" and associating them with specific syntactic
  186. symbols (see *Note Syntactic Symbols::).  CC Mode itself uses custom
  187. indentation functions to provide more sophisticated indentation, for
  188. example when lining up C++ stream operator blocks:
  189.  
  190.      1: void main(int argc, char**)
  191.      2: {
  192.      3:   cout << "There were "
  193.      4:     << argc
  194.      5:     << "arguments passed to the program"
  195.      6:     << endl;
  196.      7: }
  197.  
  198.    In this example, lines 4 through 6 are assigned the `stream-op'
  199. syntactic symbol.  Here, `stream-op' has an offset of `+', and with a
  200. `c-basic-offset' of 2, you can see that lines 4 through 6 are simply
  201. indented two spaces to the right of line 3.  But perhaps we'd like CC
  202. Mode to be a little more intelligent so that it aligns all the `<<'
  203. symbols in lines 3 through 6.  To do this, we have to write a custom
  204. indentation function which finds the column of first stream operator on
  205. the first line of the statement.  Here is sample lisp code implementing
  206. this:
  207.  
  208.      (defun c-lineup-streamop (langelem)
  209.        ;; lineup stream operators
  210.        (save-excursion
  211.          (let* ((relpos (cdr langelem))
  212.                 (curcol (progn (goto-char relpos)
  213.                                (current-column))))
  214.            (re-search-forward "<<\\|>>" (c-point 'eol) 'move)
  215.            (goto-char (match-beginning 0))
  216.            (- (current-column) curcol))))
  217.  
  218. Custom indent functions take a single argument, which is a syntactic
  219. component cons cell (see *Note Syntactic Analysis::).  The function
  220. returns an integer offset value that will be added to the running total
  221. indentation for the line.  Note that what actually gets returned is the
  222. difference between the column that the first stream operator is on, and
  223. the column of the buffer relative position passed in the function's
  224. argument.  Remember that CC Mode automatically adds in the column of
  225. the component's relative buffer position and we don't the column offset
  226. added in twice.
  227.  
  228.    Now, to associate the function `c-lineup-streamop' with the
  229. `stream-op' syntactic symbol, we can add something like the following
  230. to our `c++-mode-hook'(1):
  231.  
  232.      (c-set-offset 'stream-op 'c-lineup-streamop)
  233.  
  234.    Now the function looks like this after re-indenting (using `C-c
  235. C-q'):
  236.  
  237.      1: void main(int argc, char**)
  238.      2: {
  239.      3:   cout << "There were "
  240.      4:        << argc
  241.      5:        << "arguments passed to the program"
  242.      6:        << endl;
  243.      7: }
  244.  
  245.    Custom indentation functions can be as simple or as complex as you
  246. like, and any syntactic symbol that appears in `c-offsets-alist' can
  247. have a custom indentation function associated with it.  CC Mode comes
  248. with several standard custom indentation functions, not all of which are
  249. used by the default styles.
  250.  
  251.    * `c-lineup-arglist' -- lines up function argument lines under the
  252.      argument on the previous line.
  253.  
  254.    * `c-lineup-arglist-intro-after-paren' -- similar to
  255.      `c-lineup-arglist', but works for argument lists that begin with an
  256.      open parenthesis followed by a newline.
  257.  
  258.    * `c-lineup-arglist-close-under-paren' -- set your `arglist-close'
  259.      syntactic symbol to this line-up function so that parentheses that
  260.      close argument lists will line up under the parenthesis that
  261.      opened the argument list.
  262.  
  263.    * `c-lineup-streamop' -- lines up C++ stream operators (e.g. `<<'
  264.      and `>>').
  265.  
  266.    * `c-lineup-multi-inher' -- lines up multiple inheritance lines.
  267.  
  268.    * `c-lineup-C-comments' -- lines up C block comment continuation
  269.      lines.
  270.  
  271.    * `c-lineup-comment' -- lines up comment only lines according to the
  272.      variable `c-comment-only-line-offset'.
  273.  
  274.    * `c-lineup-runin-statements' -- lines up `statement's for coding
  275.      standards which place the first statement in a block on the same
  276.      line as the block opening brace(2).
  277.  
  278.    * `c-lineup-math' -- lines up math `statement-cont' lines under the
  279.      previous line after the equals sign.
  280.  
  281.    * `c-lineup-ObjC-method-call' -- for Objective-C code, lines up
  282.      selector arguments just after the message receiver.
  283.  
  284.    * `c-lineup-ObjC-method-args' -- for Objective-C code, lines up the
  285.      colons that separate arguments by aligning colons vertically.
  286.  
  287.    * `c-lineup-ObjC-method-args-2' -- similar to
  288.      `c-lineup-ObjC-method-args' but lines up the colon on the current
  289.      line with the colon on the previous line.
  290.  
  291.    ---------- Footnotes ----------
  292.  
  293.    (1) It probably makes more sense to add this to `c++-mode-hook' than
  294. `c-mode-common-hook' since stream operators are only relevent for C++.
  295.  
  296.    (2) Run-in style doesn't really work too well.  You might need to
  297. write your own custom indentation functions to better support this
  298. style.
  299.  
  300. 
  301. File: cc-mode.info,  Node: Custom Brace and Colon Hanging,  Next: Customizing Semi-colons and Commas,  Prev: Custom Indentation Functions,  Up: Advanced Customizations
  302.  
  303. Custom Brace and Colon Hanging
  304. ------------------------------
  305.  
  306.    Syntactic symbols aren't the only place where you can customize CC
  307. Mode with the lisp equivalent of callback functions.  Brace "hanginess"
  308. can also be determined by custom functions associated with syntactic
  309. symbols on the `c-hanging-braces-alist' variable.  Remember that
  310. ACTION's are typically a list containing some combination of the
  311. symbols `before' and `after' (see *Note Hanging Braces::).  However, an
  312. ACTION can also be a function which gets called when a brace matching
  313. that syntactic symbol is entered.
  314.  
  315.    These ACTION functions are called with two arguments: the syntactic
  316. symbol for the brace, and the buffer position at which the brace was
  317. inserted.  The ACTION function is expected to return a list containing
  318. some combination of `before' and `after'.  The function can also return
  319. `nil'.  This return value has the normal brace hanging semantics.
  320.  
  321.    As an example, CC Mode itself uses this feature to dynamically
  322. determine the hanginess of braces which close "do-while" constructs:
  323.  
  324.      void do_list( int count, char** atleast_one_string )
  325.      {
  326.          int i=0;
  327.          do {
  328.              handle_string( atleast_one_string[i] );
  329.              i++;
  330.          } while( i < count );
  331.      }
  332.  
  333.    CC Mode assigns the `block-close' syntactic symbol to the brace that
  334. closes the `do' construct, and normally we'd like the line that follows
  335. a `block-close' brace to begin on a separate line.  However, with
  336. "do-while" constructs, we want the `while' clause to follow the closing
  337. brace.  To do this, we associate the `block-close' symbol with the
  338. ACTION function `c-snug-do-while':
  339.  
  340.      (defun c-snug-do-while (syntax pos)
  341.        "Dynamically calculate brace hanginess for do-while statements.
  342.      Using this function, `while' clauses that end a `do-while' block will
  343.      remain on the same line as the brace that closes that block.
  344.      
  345.      See `c-hanging-braces-alist' for how to utilize this function as an
  346.      ACTION associated with `block-close' syntax."
  347.        (save-excursion
  348.          (let (langelem)
  349.            (if (and (eq syntax 'block-close)
  350.                     (setq langelem (assq 'block-close c-syntactic-context))
  351.                     (progn (goto-char (cdr langelem))
  352.                            (if (= (following-char) ?{)
  353.                                (forward-sexp -1))
  354.                            (looking-at "\\<do\\>[^_]")))
  355.                '(before)
  356.              '(before after)))))
  357.  
  358.    This function simply looks to see if the brace closes a "do-while"
  359. clause and if so, returns the list `(before)' indicating that a newline
  360. should be inserted before the brace, but not after it.  In all other
  361. cases, it returns the list `(before after)' so that the brace appears
  362. on a line by itself.
  363.  
  364.    During the call to the brace hanging ACTION function, the variable
  365. `c-syntactic-context' is bound to the full syntactic analysis list.
  366.  
  367.    Note that for symmetry, colon hanginess should be customizable by
  368. allowing function symbols as ACTIONs on the `c-hanging-colon-alist'
  369. variable.  Since no use has actually been found for this feature, it
  370. isn't currently implemented!
  371.  
  372. 
  373. File: cc-mode.info,  Node: Customizing Semi-colons and Commas,  Next: Other Special Indentations,  Prev: Custom Brace and Colon Hanging,  Up: Advanced Customizations
  374.  
  375. Customizing Semi-colons and Commas
  376. ----------------------------------
  377.  
  378.    You can also customize the insertion of newlines after semi-colons
  379. and commas, when the auto-newline minor mode is enabled (see *Note
  380. Minor Modes::).  This is controlled by the variable
  381. `c-hanging-semi&comma-criteria', which contains a list of functions
  382. that are called in the order they appear.  Each function is called with
  383. zero arguments, and is expected to return one of the following values:
  384.  
  385.    * non-`nil' -- A newline is inserted, and no more functions from the
  386.      list are called.
  387.  
  388.    * `stop' -- No more functions from the list are called, but no
  389.      newline is inserted.
  390.  
  391.    * `nil' -- No determination is made, and the next function in the
  392.      list is called.
  393.  
  394.    If every function in the list is called without a determination being
  395. made, then no newline is added. The default value for this variable is a
  396. list containing a single function which inserts newlines only after
  397. semi-colons which do not appear inside parenthesis lists (i.e. those
  398. that separate `for'-clause statements).
  399.  
  400.    Here's an example of a criteria function that will prevent newlines
  401. from being inserted after semicolons when there is a non-blank following
  402. line.  Otherwise, it makes no determination.  To use, add this to the
  403. front of the `c-hanging-semi&comma-criteria' list.
  404.  
  405.  
  406.      (defun my-semicolon-criteria ()
  407.        (save-excursion
  408.          (if (and (eq last-command-char ?\;)
  409.                   (zerop (forward-line 1))
  410.                   (not (looking-at "^[ \t]*$")))
  411.              'stop
  412.            nil)))
  413.  
  414. 
  415. File: cc-mode.info,  Node: Other Special Indentations,  Prev: Customizing Semi-colons and Commas,  Up: Advanced Customizations
  416.  
  417. Other Special Indentations
  418. --------------------------
  419.  
  420.    In `gnu' style (see *Note Built-in Styles::), a minimum indentation
  421. is imposed on lines inside top-level constructs.  This minimum
  422. indentation is controlled by the variable
  423. `c-label-minimum-indentation'.  The default value for this variable is
  424. 1.
  425.  
  426.    One other customization variable is available in CC Mode:
  427. `c-special-indent-hook'.  This is a standard hook variable that is
  428. called after every line is indented by CC Mode.  You can use it to do
  429. any special indentation or line adjustments your style dictates, such
  430. as adding extra indentation to constructors or destructor declarations
  431. in a class definition, etc.  Note however, that you should not change
  432. point or mark inside your `c-special-indent-hook' functions (i.e.
  433. you'll probably want to wrap your function in a `save-excursion').
  434.  
  435.    Setting `c-special-indent-hook' in your style definition is handled
  436. slightly differently than other variables.  In your style definition,
  437. you should set the value for `c-special-indent-hook' to a function or
  438. list of functions, which will be appended to `c-special-indent-hook'
  439. using `add-hook'.  That way, the current setting for the buffer local
  440. value of `c-special-indent-hook' won't be overridden.
  441.  
  442.    Normally, the standard Emacs command `M-;' (`indent-for-comment')
  443. will indent comment only lines to `comment-column'.  Some users
  444. however, prefer that `M-;' act just like `TAB' for purposes of
  445. indenting comment-only lines; i.e. they want the comments to always
  446. indent as they would for normal code, regardless of whether `TAB' or
  447. `M-;' were used.  This behavior is controlled by the variable
  448. `c-indent-comments-syntactically-p'.  When `nil' (the default), `M-;'
  449. indents comment-only lines to `comment-column', otherwise, they are
  450. indented just as they would be if `TAB' were typed.
  451.  
  452. 
  453. File: cc-mode.info,  Node: Syntactic Symbols,  Next: Performance Issues,  Prev: Customizing Indentation,  Up: Top
  454.  
  455. Syntactic Symbols
  456. *****************
  457.  
  458.    Here is a complete list of the recognized syntactic symbols as
  459. described in the `c-offsets-alist' variable, along with a brief
  460. description.  More detailed descriptions follow below.
  461.  
  462.    * `string' -- inside multi-line string
  463.  
  464.    * `c' -- inside a multi-line C style block comment
  465.  
  466.    * `defun-open' -- brace that opens a function definition
  467.  
  468.    * `defun-close' -- brace that closes a function definition
  469.  
  470.    * `defun-block-intro' -- the first line in a top-level defun
  471.  
  472.    * `class-open' -- brace that opens a class definition
  473.  
  474.    * `class-close' -- brace that closes a class definition
  475.  
  476.    * `inline-open' -- brace that opens an in-class inline method
  477.  
  478.    * `inline-close' -- brace that closes an in-class inline method
  479.  
  480.    * `func-decl-cont' -- the region between a function definition's
  481.      argument list and the function opening brace (excluding K&R
  482.      argument declarations).  In C, you cannot put anything but
  483.      whitespace and comments between them; in C++ and Java, `throws'
  484.      declarations and other things can appear in this context.
  485.  
  486.    * `knr-argdecl-intro' -- first line of a K&R C argument declaration
  487.  
  488.    * `knr-argdecl' -- subsequent lines in a K&R C argument declaration
  489.  
  490.    * `topmost-intro' -- the first line in a topmost definition
  491.  
  492.    * `topmost-intro-cont' -- topmost definition continuation lines
  493.  
  494.    * `member-init-intro' -- first line in a member initialization list
  495.  
  496.    * `member-init-cont' -- subsequent member initialization list lines
  497.  
  498.    * `inher-intro' -- first line of a multiple inheritance list
  499.  
  500.    * `inher-cont' -- subsequent multiple inheritance lines
  501.  
  502.    * `block-open' -- statement block open brace
  503.  
  504.    * `block-close' -- statement block close brace
  505.  
  506.    * `brace-list-open' -- open brace of an enum or static array list
  507.  
  508.    * `brace-list-close' -- close brace of an enum or static array list
  509.  
  510.    * `brace-list-intro' -- first line in an enum or static array list
  511.  
  512.    * `brace-list-entry' -- subsequent lines in an enum or static array
  513.      list
  514.  
  515.    * `statement' -- a C statement
  516.  
  517.    * `statement-cont' -- a continuation of a C statement
  518.  
  519.    * `statement-block-intro' -- the first line in a new statement block
  520.  
  521.    * `statement-case-intro' -- the first line in a case `block'
  522.  
  523.    * `statement-case-open' -- the first line in a case block starting
  524.      with brace
  525.  
  526.    * `substatement' -- the first line after a conditional
  527.  
  528.    * `substatement-open' -- the brace that opens a substatement block
  529.  
  530.    * `case-label' -- a case or default label
  531.  
  532.    * `access-label' -- C++ access control label
  533.  
  534.    * `label' -- any non-special C label
  535.  
  536.    * `do-while-closure' -- the `while' that ends a `do'-`while'
  537.      construct
  538.  
  539.    * `else-clause' -- the `else' of an `if'-`else' construct
  540.  
  541.    * `comment-intro' -- a line containing only a comment introduction
  542.  
  543.    * `arglist-intro' -- the first line in an argument list
  544.  
  545.    * `arglist-cont' -- subsequent argument list lines when no arguments
  546.      follow on the same line as the the arglist opening paren
  547.  
  548.    * `arglist-cont-nonempty' -- subsequent argument list lines when at
  549.      least one argument follows on the same line as the arglist opening
  550.      paren
  551.  
  552.    * `arglist-close' -- the solo close paren of an argument list
  553.  
  554.    * `stream-op' -- lines continuing a stream operator
  555.  
  556.    * `inclass' -- the line is nested inside a class definition
  557.  
  558.    * `cpp-macro' -- the start of a cpp macro
  559.  
  560.    * `friend' -- a C++ friend declaration
  561.  
  562.    * `objc-method-intro' -- the first line of an Objective-C method
  563.      definition
  564.  
  565.    * `objc-method-args-cont' -- lines continuing an Objective-C method
  566.      definition
  567.  
  568.    * `objc-method-call-cont' -- lines continuing an Objective-C method
  569.      call
  570.  
  571.    * `extern-lang-open' -- brace that opens an external language block
  572.  
  573.    * `extern-lang-close' -- brace that closes an external language block
  574.  
  575.    * `inextern-lang' -- analogous to `inclass' syntactic symbol, but
  576.      for `extern' blocks.
  577.  
  578.    * `template-args-cont' -- C++ template argument list continuations
  579.  
  580.    Most syntactic symbol names follow a general naming convention.
  581. When a line begins with an open or close brace, the syntactic symbol
  582. will contain the suffix `-open' or `-close' respectively.
  583.  
  584.    Usually, a distinction is made between the first line that
  585. introduces a construct and lines that continue a construct, and the
  586. syntactic symbols that represent these lines will contain the suffix
  587. `-intro' or `-cont' respectively.  As a sub-classification of this
  588. scheme, a line which is the first of a particular brace block construct
  589. will contain the suffix `-block-intro'.
  590.  
  591.    Let's look at some examples to understand how this works.  Remember
  592. that you can check the syntax of any line by using `C-c C-s'.
  593.  
  594.        1: void
  595.        2: swap( int& a, int& b )
  596.        3: {
  597.        4:     int tmp = a;
  598.        5:     a = b;
  599.        6:     b = tmp;
  600.        7:     int ignored =
  601.        8:         a + b;
  602.        9: }
  603.  
  604.    Line 1 shows a `topmost-intro' since it is the first line that
  605. introduces a top-level construct.  Line 2 is a continuation of the
  606. top-level construct introduction so it has the syntax
  607. `topmost-intro-cont'.  Line 3 shows a `defun-open' since it is the
  608. brace that opens a top-level function definition.  Line 9 is a
  609. `defun-close' since it contains the brace that closes the top-level
  610. function definition.  Line 4 is a `defun-block-intro', i.e. it is the
  611. first line of a brace-block, enclosed in a top-level function
  612. definition.
  613.  
  614.    Lines 5, 6, and 7 are all given `statement' syntax since there isn't
  615. much special about them.  Note however that line 8 is given
  616. `statement-cont' syntax since it continues the statement begun on the
  617. previous line.
  618.  
  619.    Here's another example, which illustrates some C++ class syntactic
  620. symbols:
  621.  
  622.         1: class Bass
  623.         2:     : public Guitar,
  624.         3:       public Amplifiable
  625.         4: {
  626.         5: public:
  627.         6:     Bass()
  628.         7:         : eString( new BassString( 0.105 )),
  629.         8:           aString( new BassString( 0.085 )),
  630.         9:           dString( new BassString( 0.065 )),
  631.        10:           gString( new BassString( 0.045 ))
  632.        11:     {
  633.        12:         eString.tune( 'E' );
  634.        13:         aString.tune( 'A' );
  635.        14:         dString.tune( 'D' );
  636.        15:         gString.tune( 'G' );
  637.        16:     }
  638.        17:     friend class Luthier;
  639.        18: }
  640.  
  641.    As in the previous example, line 1 has the `topmost-intro' syntax.
  642. Here however, the brace that opens a C++ class definition on line 4 is
  643. assigned the `class-open' syntax.  Note that in C++, classes, structs,
  644. and unions are essentially equivalent syntactically (and are very
  645. similar semantically), so replacing the `class' keyword in the example
  646. above with `struct' or `union' would still result in a syntax of
  647. `class-open' for line 4 (1).  Similarly, line 18 is assigned
  648. `class-close' syntax.
  649.  
  650.    Line 2 introduces the inheritance list for the class so it is
  651. assigned the `inher-intro' syntax, and line 3, which continues the
  652. inheritance list is given `inher-cont' syntax.
  653.  
  654.    Hitting `C-c C-s' on line 5 shows the following analysis:
  655.  
  656.  
  657.      `((inclass . 1) (access-label . 67))'
  658.  
  659. The primary syntactic symbol for this line is `access-label' as this a
  660. label keyword that specifies access protection in C++.  However,
  661. because this line is also a top-level construct inside a class
  662. definition, the analysis actually shows two syntactic symbols.  The
  663. other syntactic symbol assigned to this line is `inclass'.  Similarly,
  664. line 6 is given both `inclass' and `topmost-intro' syntax:
  665.  
  666.  
  667.      `((inclass . 58) (topmost-intro . 60))'
  668.  
  669.    Line 7 introduces a C++ member initialization list and as such is
  670. given `member-init-intro' syntax.  Note that in this case it is *not*
  671. assigned `inclass' since this is not considered a top-level construct.
  672. Lines 8 through 10 are all assigned `member-init-cont' since they
  673. continue the member initialization list started on line 7.
  674.  
  675.    Line 11's analysis is a bit more complicated:
  676.  
  677.  
  678.      `((inclass . 1) (inline-open))'
  679.  
  680.    This line is assigned a syntax of both `inline-open' and `inclass'
  681. because it opens an "in-class" C++ inline method definition.  This is
  682. distinct from, but related to, the C++ notion of an inline function in
  683. that its definition occurs inside an enclosing class definition, which
  684. in C++ implies that the function should be inlined.  If though, the
  685. definition of the `Bass' constructor appeared outside the class
  686. definition, the construct would be given the `defun-open' syntax, even
  687. if the keyword `inline' appeared before the method name, as in:
  688.  
  689.      class Bass
  690.          : public Guitar,
  691.            public Amplifiable
  692.      {
  693.      public:
  694.          Bass();
  695.      }
  696.      
  697.      inline
  698.      Bass::Bass()
  699.          : eString( new BassString( 0.105 )),
  700.            aString( new BassString( 0.085 )),
  701.            dString( new BassString( 0.065 )),
  702.            gString( new BassString( 0.045 ))
  703.      {
  704.          eString.tune( 'E' );
  705.          aString.tune( 'A' );
  706.          dString.tune( 'D' );
  707.          gString.tune( 'G' );
  708.      }
  709.  
  710.    Returning to the previous example, line 16 is given `inline-close'
  711. syntax, while line 12 is given `defun-block-open' syntax, and lines 13
  712. through 15 are all given `statement' syntax.  Line 17 is interesting in
  713. that its syntactic analysis list contains three elements:
  714.  
  715.  
  716.      `((friend) (inclass . 58) (topmost-intro . 380))'
  717.  
  718.    The `friend' syntactic symbol is a modifier that typically does not
  719. have a relative buffer position.
  720.  
  721.    Template definitions introduce yet another syntactic symbol:
  722.  
  723.  
  724.         1: ThingManager <int,
  725.         2:    Framework::Callback *,
  726.         3:    Mutex> framework_callbacks;
  727.  
  728.    Here, line 1 is analyzed as a `topmost-intro', but lines 2 and 3 are
  729. both analyzed as `template-args-cont' lines.
  730.  
  731.    Here is another (totally contrived) example which illustrates how
  732. syntax is assigned to various conditional constructs:
  733.  
  734.         1: void spam( int index )
  735.         2: {
  736.         3:     for( int i=0; i<index; i++ )
  737.         4:     {
  738.         5:         if( i == 10 )
  739.         6:         {
  740.         7:             do_something_special();
  741.         8:         }
  742.         9:         else
  743.        10:             do_something( i );
  744.        11:     }
  745.        12:     do {
  746.        13:         another_thing( i-- );
  747.        14:     }
  748.        15:     while( i > 0 );
  749.        16: }
  750.  
  751. Only the lines that illustrate new syntactic symbols will be discussed.
  752.  
  753.    Line 4 has a brace which opens a conditional's substatement block.
  754. It is thus assigned `substatement-open' syntax, and since line 5 is the
  755. first line in the substatement block, it is assigned
  756. `substatement-block-intro' syntax.  Lines 6 and 7 are assigned similar
  757. syntax.  Line 8 contains the brace that closes the inner substatement
  758. block.  It is given the syntax `block-close', as are lines 11 and 14.
  759.  
  760.    Line 9 is a little different -- since it contains the keyword `else'
  761. matching the `if' statement introduced on line 5, it is given the
  762. `else-clause' syntax.  Note also that line 10 is slightly different
  763. too.  Because `else' is considered a conditional introducing keyword
  764. (2), and because the following substatement is not a brace block, line
  765. 10 is assigned the `substatement' syntax.
  766.  
  767.    One other difference is seen on line 15.  The `while' construct that
  768. closes a `do' conditional is given the special syntax
  769. `do-while-closure' if it appears on a line by itself.  Note that if the
  770. `while' appeared on the same line as the preceding close brace, that
  771. line would have been assigned `block-close' syntax instead.
  772.  
  773.    Switch statements have their own set of syntactic symbols.  Here's an
  774. example:
  775.  
  776.         1: void spam( enum Ingredient i )
  777.         2: {
  778.         3:     switch( i ) {
  779.         4:     case Ham:
  780.         5:         be_a_pig();
  781.         6:         break;
  782.         7:     case Salt:
  783.         8:         drink_some_water();
  784.         9:         break;
  785.        10:     default:
  786.        11:         {
  787.        12:             what_is_it();
  788.        13:             break;
  789.        14:         }
  790.        15:     }
  791.        14: }
  792.  
  793.    Here, lines 4, 7, and 10 are all assigned `case-label' syntax, while
  794. lines 5 and 8 are assigned `statement-case-intro'.  Line 11 is treated
  795. slightly differently since it contains a brace that opens a block -- it
  796. is given `statement-case-open' syntax.
  797.  
  798.    There are a set of syntactic symbols that are used to recognize
  799. constructs inside of brace lists.  A brace list is defined as an `enum'
  800. or aggregate initializer list, such as might statically initialize an
  801. array of structs.  For example:
  802.  
  803.        1: static char* ingredients[] =
  804.        2: {
  805.        3:     "Ham",
  806.        4:     "Salt",
  807.        5:     NULL
  808.        6: }
  809.  
  810.    Following convention, line 2 in this example is assigned
  811. `brace-list-open' syntax, and line 3 is assigned `brace-list-intro'
  812. syntax.  Likewise, line 6 is assigned `brace-list-close' syntax.  Lines
  813. 4 and 5 however, are assigned `brace-list-entry' syntax, as would all
  814. subsequent lines in this initializer list.
  815.  
  816.    External language definition blocks also have their own syntactic
  817. symbols.  In this example:
  818.  
  819.         1: extern "C"
  820.         2: {
  821.         3:     int thing_one( int );
  822.         4:     int thing_two( double );
  823.         5: }
  824.  
  825. line 2 is given the `extern-lang-open' syntax while line 5 is given the
  826. `extern-lang-close' syntax.  The analysis for line 3 yields:
  827. `((inextern-lang) (topmost-intro . 14))', where `inextern-lang' is a
  828. modifier similar in purpose to `inclass'.
  829.  
  830.    A number of syntactic symbols are associated with parenthesis lists,
  831. a.k.a argument lists, as found in function declarations and function
  832. calls.  This example illustrates these:
  833.  
  834.         1: void a_function( int line1,
  835.         2:                  int line2 );
  836.         3:
  837.         4: void a_longer_function(
  838.         5:     int line1,
  839.         6:     int line2
  840.         7:     );
  841.         8:
  842.         9: void call_them( int line1, int line2 )
  843.        10: {
  844.        11:     a_function(
  845.        12:         line1,
  846.        13:         line2
  847.        14:         );
  848.        15:
  849.        16:     a_longer_function( line1,
  850.        17:                        line2 );
  851.        18: }
  852.  
  853.    Lines 5 and 12 are assigned `arglist-intro' syntax since they are
  854. the first line following the open parenthesis, and lines 7 and 14 are
  855. assigned `arglist-close' syntax since they contain the parenthesis that
  856. closes the argument list.
  857.  
  858.    Lines that continue argument lists can be assigned one of two
  859. syntactic symbols.  For example, Lines 2 and 17 are assigned
  860. `arglist-cont-nonempty' syntax.  What this means is that they continue
  861. an argument list, but that the line containing the parenthesis that
  862. opens the list is *not empty* following the open parenthesis.  Contrast
  863. this against lines 6 and 13 which are assigned `arglist-cont' syntax.
  864. This is because the parenthesis that opens their argument lists is the
  865. last character on that line.
  866.  
  867.    Note that there is no `arglist-open' syntax.  This is because any
  868. parenthesis that opens an argument list, appearing on a separate line,
  869. is assigned the `statement-cont' syntax instead.
  870.  
  871.    A few miscellaneous syntactic symbols that haven't been previously
  872. covered are illustrated by this C++ example:
  873.  
  874.         1: void Bass::play( int volume )
  875.         2: const
  876.         3: {
  877.         4:     /* this line starts a multi-line
  878.         5:      * comment.  This line should get `c' syntax */
  879.         6:
  880.         7:     char* a_multiline_string = "This line starts a multi-line \
  881.         8: string.  This line should get `string' syntax.";
  882.         9:
  883.        10:   note:
  884.        11:     {
  885.        12: #ifdef LOCK
  886.        13:         Lock acquire();
  887.        14: #endif // LOCK
  888.        15:         slap_pop();
  889.        16:         cout << "I played "
  890.        17:              << "a note\n";
  891.        18:     }
  892.        19: }
  893.  
  894.    The lines to note in this example include:
  895.  
  896.    * line 2, assigned the `func-decl-cont' syntax;
  897.  
  898.    * line 4, assigned both `defun-block-intro' *and* `comment-intro'
  899.      syntax;
  900.  
  901.    * line 5, assigned `c' syntax;
  902.  
  903.    * line 6 which, even though it contains nothing but whitespace, is
  904.      assigned `defun-block-intro'.  Note that the appearance of the
  905.      comment on lines 4 and 5 do not cause line 6 to be assigned
  906.      `statement' syntax because comments are considered to be
  907.      "syntactic whitespace", which are ignored when analyzing code;
  908.  
  909.    * line 8, assigned `string' syntax;
  910.  
  911.    * line 10, assigned `label' syntax;
  912.  
  913.    * line 11, assigned `block-open' syntax;
  914.  
  915.    * lines 12 and 14, assigned `cpp-macro' syntax;
  916.  
  917.    * line 17, assigned `stream-op' syntax.
  918.  
  919.    In Objective-C buffers, there are three additional syntactic symbols
  920. assigned to various message calling constructs.  Here's an example
  921. illustrating these:
  922.  
  923.        1: - (void)setDelegate:anObject
  924.        2:           withStuff:stuff
  925.        3: {
  926.        4:     [delegate masterWillRebind:self
  927.        5:               toDelegate:anObject
  928.        6:               withExtraStuff:stuff];
  929.        7: }
  930.  
  931.    Here, line 1 is assigned `objc-method-intro' syntax, and line 2 is
  932. assigned `objc-method-args-cont' syntax.  Lines 5 and 6 are both
  933. assigned `objc-method-call-cont' syntax.
  934.  
  935.    Two other syntactic symbols can appear in old style, non-prototyped C
  936. code (3):
  937.  
  938.        1: int add_three_integers(a, b, c)
  939.        2:      int a;
  940.        3:      int b;
  941.        4:      int c;
  942.        5: {
  943.        6:     return a + b + c;
  944.        7: }
  945.  
  946.    Here, line 2 is the first line in an argument declaration list and
  947. so is given the `knr-argdecl-intro' syntactic symbol.  Subsequent lines
  948. (i.e. lines 3 and 4 in this example), are given `knr-argdecl' syntax.
  949.  
  950.    ---------- Footnotes ----------
  951.  
  952.    (1) This is the case even for C and Objective-C.  For consistency,
  953. structs in all supported languages are syntactically equivalent to
  954. classes.  Note however that the keyword `class' is meaningless in C and
  955. Objective-C.
  956.  
  957.    (2) The list of conditional keywords are (in C, C++, Objective-C,
  958. and Java): `for', `if', `do', `else', `while', and `switch'.  C++ and
  959. Java have two additional conditional keywords: `try' and `catch'.  Java
  960. also has the `finally' and `synchronized' keywords.
  961.  
  962.    (3) a.k.a. K&R C, or Kernighan & Ritchie C
  963.  
  964. 
  965. File: cc-mode.info,  Node: Performance Issues,  Next: Frequently Asked Questions,  Prev: Syntactic Symbols,  Up: Top
  966.  
  967. Performance Issues
  968. ******************
  969.  
  970.    C and its derivative languages are highly complex creatures.  Often,
  971. ambiguous code situations arise that require CC Mode to scan large
  972. portions of the buffer to determine syntactic context.  Such
  973. pathological code(1) can cause CC Mode to perform fairly badly.  This
  974. section identifies some of the coding styles to watch out for, and
  975. suggests some workarounds that you can use to improve performance.
  976.  
  977.    Because CC Mode has to scan the buffer backwards from the current
  978. insertion point, and because C's syntax is fairly difficult to parse in
  979. the backwards direction, CC Mode often tries to find the nearest
  980. position higher up in the buffer from which to begin a forward scan.
  981. The farther this position is from the current insertion point, the
  982. slower the mode gets.  Some coding styles can even force CC Mode to
  983. scan from the beginning of the buffer for every line of code!
  984.  
  985.    One of the simplest things you can do to reduce scan time, is make
  986. sure any brace that opens a top-level block construct always appears in
  987. the leftmost column.  This is actually an Emacs constraint, as embodied
  988. in the `beginning-of-defun' function which CC Mode uses heavily.  If
  989. you insist on hanging top-level open braces on the right side of the
  990. line, then you should set the variable `defun-prompt-regexp' to
  991. something reasonable (2), however that "something reasonable" is
  992. difficult to define, so CC Mode doesn't do it for you.
  993.  
  994.    A special note about `defun-prompt-regexp' in Java mode: while much
  995. of the early sample Java code seems to encourage a style where the brace
  996. that opens a class is hung on the right side of the line, this is not a
  997. good style to pursue in Emacs.  CC Mode comes with a variable
  998. `c-Java-defun-prompt-regexp' which tries to define a regular expression
  999. usable for this style, but there are problems with it.  In some cases
  1000. it can cause `beginning-of-defun' to hang(3).  For this reason, it is
  1001. not used by default, but if you feel adventurous, you can set
  1002. `defun-prompt-regexp' to it in your mode hook.  In any event, setting
  1003. and rely on `defun-prompt-regexp' will definitely slow things down!
  1004.  
  1005.    You will probably notice pathological behavior from CC Mode when
  1006. working in files containing large amounts of cpp macros.  This is
  1007. because Emacs cannot be made to quickly skip backwards over these lines.
  1008.  
  1009.    Previous versions of CC Mode had potential performance problems when
  1010. recognizing K&R style function argument declarations.  This was because
  1011. there are ambiguities in the C syntax when K&R style argument lists are
  1012. used(4).  CC Mode has adopted BOCM's convention for limiting the
  1013. search: it assumes that argdecls are indented at least one space, and
  1014. that the function headers are not indented at all.  With current
  1015. versions of CC Mode, user customization of `c-recognize-knr-p' is
  1016. deprecated.  Just don't put argdecls in column zero!
  1017.  
  1018.    You might want to investigate the speed-ups contained in the file
  1019. `cc-lobotomy.el', which comes as part of the CC Mode distribution, but
  1020. is completely unsupported.  As mentioned previous, CC Mode always
  1021. trades accuracy for speed, however it is recognized that sometimes you
  1022. need speed and can sacrifice some accuracy in indentation.  The file
  1023. `cc-lobotomy.el' contains hacks that will "dumb down" CC Mode in some
  1024. specific ways, making that trade-off of speed for accuracy.  I won't go
  1025. into details of its use here; you should read the comments at the top
  1026. of the file, and look at the variable `cc-lobotomy-pith-list' for
  1027. details.
  1028.  
  1029.    ---------- Footnotes ----------
  1030.  
  1031.    (1) such as the output of `lex(1)'!
  1032.  
  1033.    (2) Note that this variable is only defined in Emacs 19.
  1034.  
  1035.    (3) This has been observed in Emacs 19.34 and XEmacs 19.15.
  1036.  
  1037.    (4) It is hard to distinguish them from top-level declarations.
  1038.  
  1039. 
  1040. File: cc-mode.info,  Node: Frequently Asked Questions,  Next: Getting the latest CC Mode release,  Prev: Performance Issues,  Up: Top
  1041.  
  1042. Frequently Asked Questions
  1043. **************************
  1044.  
  1045.      *Q.* *How do I re-indent the whole file?*
  1046.  
  1047.      *A.* Visit the file and hit `C-x h' to mark the whole buffer. Then
  1048.      hit `<ESC> C-\'.
  1049.  
  1050.      *Q.* *How do I re-indent the entire function?  `<ESC> C-x' doesn't
  1051.      work.*
  1052.  
  1053.      *A.* `<ESC> C-x' is reserved for future Emacs use.  To re-indent
  1054.      the entire function hit `C-c C-q'.
  1055.  
  1056.      *Q.* *How do I re-indent the current block?*
  1057.  
  1058.      *A.* First move to the brace which opens the block with `<ESC>
  1059.      C-u', then re-indent that expression with `<ESC> C-q'.
  1060.  
  1061.      *Q.* *Why doesn't the <RET> key indent the line to where the new
  1062.      text should go after inserting the newline?*
  1063.  
  1064.      *A.* Emacs' convention is that <RET> just adds a newline, and that
  1065.      <C-j> adds a newline and indents it.  You can make <RET> do this
  1066.      too by adding this to your `c-mode-common-hook' (see the sample
  1067.      `.emacs' file *Note Sample .emacs File::):
  1068.  
  1069.           (define-key c-mode-base-map "\C-m" 'newline-and-indent)
  1070.  
  1071.      This is a very common question.  If you want this to be the default
  1072.      behavior, don't lobby me, lobby RMS!  `:-)'
  1073.  
  1074.      *Q.* *I put `(c-set-offset 'substatement-open 0)' in my `.emacs'
  1075.      file but I get an error saying that `c-set-offset''s function
  1076.      definition is void.*
  1077.  
  1078.      *A.* This means that CC Mode wasn't loaded into your Emacs session
  1079.      by the time the `c-set-offset' call was reached, mostly likely
  1080.      because CC Mode is being autoloaded.  Instead of putting the
  1081.      `c-set-offset' line in your top-level `.emacs' file, put it in
  1082.      your `c-mode-common-hook', or simply add the following to the top
  1083.      of your `.emacs' file:
  1084.  
  1085.           (require 'cc-mode)
  1086.  
  1087.      See the sample `.emacs' file *Note Sample .emacs File:: for
  1088.      details.
  1089.  
  1090.      *Q.* *How do I make strings, comments, keywords, and other
  1091.      constructs appear in different colors, or in bold face, etc.?*
  1092.  
  1093.      *A.* "Syntax Colorization" is a standard Emacs feature, controlled
  1094.      by `font-lock-mode'.  It is not part of CC Mode.
  1095.  
  1096.  
  1097. 
  1098. File: cc-mode.info,  Node: Getting the latest CC Mode release,  Next: Sample .emacs File,  Prev: Frequently Asked Questions,  Up: Top
  1099.  
  1100. Getting the latest CC Mode release
  1101. **********************************
  1102.  
  1103.    CC Mode is now standard with later versions Emacs 19 and XEmacs 19.
  1104. It is also the standard for XEmacs 20, and will be the standard for
  1105. Emacs 20 (unreleased as of this writing).  You would typically just use
  1106. the version that comes with your X/Emacs.  These may be slightly out of
  1107. date due to release schedule skew, so you should always check the
  1108. canonical site for the latest version.
  1109.  
  1110.  
  1111.          World Wide Web:
  1112.      
  1113.              `http://www.python.org/ftp/emacs/'
  1114.      
  1115.          Anonymous FTP:
  1116.      
  1117.              `ftp://ftp.python.org/pub/emacs/'
  1118.  
  1119.    There are many files under these directories; you can pick up the
  1120. entire distribution (named `cc-mode.tar.gz'; a gzip'd tar file), or any
  1121. of the individual files, including PostScript documentation.
  1122.  
  1123.    If you do not have World Wide Web, or anonymous ftp access, you can
  1124. get the distribution through an anonymous ftp-to-mail gateway, such as
  1125. the one run by DEC at:
  1126.  
  1127.      `ftpmail@decwrl.dec.com'
  1128.    To get CC Mode via email, send the following message in the body of
  1129. your mail to that address:
  1130.  
  1131.      reply <a valid net address back to you>
  1132.      connect ftp.python.org
  1133.      binary
  1134.      uuencode
  1135.      chdir pub/emacs
  1136.      get cc-mode.tar.gz
  1137.  
  1138. or just send the message "help" for more information on ftpmail.
  1139. Response times will vary with the number of requests in the queue.  I am
  1140. in no way connected to this service, so I make no claims or guarantees
  1141. about its availability!
  1142.  
  1143. 
  1144. File: cc-mode.info,  Node: Sample .emacs File,  Next: Limitations and Known Bugs,  Prev: Getting the latest CC Mode release,  Up: Top
  1145.  
  1146. Sample .emacs file
  1147. ******************
  1148.  
  1149.      ;; Here's a sample .emacs file that might help you along the way.  Just
  1150.      ;; copy this region and paste it into your .emacs file.  You may want to
  1151.      ;; change some of the actual values.
  1152.      
  1153.      (defconst my-c-style
  1154.        '((c-tab-always-indent        . t)
  1155.          (c-comment-only-line-offset . 4)
  1156.          (c-hanging-braces-alist     . ((substatement-open after)
  1157.                                         (brace-list-open)))
  1158.          (c-hanging-colons-alist     . ((member-init-intro before)
  1159.                                         (inher-intro)
  1160.                                         (case-label after)
  1161.                                         (label after)
  1162.                                         (access-label after)))
  1163.          (c-cleanup-list             . (scope-operator
  1164.                                         empty-defun-braces
  1165.                                         defun-close-semi))
  1166.          (c-offsets-alist            . ((arglist-close . c-lineup-arglist)
  1167.                                         (substatement-open . 0)
  1168.                                         (case-label        . 4)
  1169.                                         (block-open        . 0)
  1170.                                         (knr-argdecl-intro . -)))
  1171.          (c-echo-syntactic-information-p . t)
  1172.          )
  1173.        "My C Programming Style")
  1174.      
  1175.      ;; Customizations for all of c-mode, c++-mode, and objc-mode
  1176.      (defun my-c-mode-common-hook ()
  1177.        ;; add my personal style and set it for the current buffer
  1178.        (c-add-style "PERSONAL" my-c-style t)
  1179.        ;; offset customizations not in my-c-style
  1180.        (c-set-offset 'member-init-intro '++)
  1181.        ;; other customizations
  1182.        (setq tab-width 8
  1183.              ;; this will make sure spaces are used instead of tabs
  1184.              indent-tabs-mode nil)
  1185.        ;; we like auto-newline and hungry-delete
  1186.        (c-toggle-auto-hungry-state 1)
  1187.        ;; keybindings for all supported languages.  We can put these in
  1188.        ;; c-mode-base-map because c-mode-map, c++-mode-map, objc-mode-map,
  1189.        ;; java-mode-map, and idl-mode-map inherit from it.
  1190.        (define-key c-mode-base-map "\C-m" 'newline-and-indent)
  1191.        )
  1192.      
  1193.      (add-hook 'c-mode-common-hook 'my-c-mode-common-hook)
  1194.  
  1195. 
  1196. File: cc-mode.info,  Node: Limitations and Known Bugs,  Next: Mailing Lists and Submitting Bug Reports,  Prev: Sample .emacs File,  Up: Top
  1197.  
  1198. Limitations and Known Bugs
  1199. **************************
  1200.  
  1201.    * Multi-line macros are not handled properly.
  1202.  
  1203.    * Re-indenting large regions or expressions can be slow.
  1204.  
  1205.    * Add-on fill packages may not work as well as CC Mode's built-in
  1206.      filling routines.  I no longer recommend you use `filladapt' to
  1207.      fill comments.
  1208.  
  1209.    * `c-indent-exp' has not been fully optimized.  It essentially
  1210.      equivalent to hitting `TAB' (`c-indent-command') on every line.
  1211.      Some information is cached from line to line, but such caching
  1212.      invariable causes inaccuracies in analysis in some bizarre
  1213.      situations.
  1214.  
  1215. 
  1216. File: cc-mode.info,  Node: Mailing Lists and Submitting Bug Reports,  Next: Concept Index,  Prev: Limitations and Known Bugs,  Up: Top
  1217.  
  1218. Mailing Lists and Submitting Bug Reports
  1219. ****************************************
  1220.  
  1221.    To report bugs, use the `C-c C-b' (`c-submit-bug-report') command.
  1222. This provides vital information I need to reproduce your problem.  Make
  1223. sure you include a concise, but complete code example.  Please try to
  1224. boil your example down to just the essential code needed to reproduce
  1225. the problem, and include an exact recipe of steps needed to expose the
  1226. bug.  Be especially sure to include any code that appears *before* your
  1227. bug example, if you think it might affect my ability to reproduce it.
  1228.  
  1229.    Bug reports are now sent to the following email addresses:
  1230. `cc-mode-help@python.org' and `bug-gnu-emacs@prep.ai.mit.edu'; the
  1231. latter is mirrored on the Usenet newsgroup `gnu.emacs.bug'.  You can
  1232. send other questions and suggestions (kudos? `;-)' to
  1233. `cc-mode-help@python.org', or `help-gnu-emacs@prep.ai.mit.edu' which is
  1234. mirrored on newsgroup `gnu.emacs.help'.
  1235.  
  1236.    If you want to get announcements of new CC Mode releases, send the
  1237. word *subscribe* in the body of a message to
  1238. `cc-mode-announce-request@python.org'.  Announcements will also be
  1239. posted to the Usenet newsgroups `gnu.emacs.sources', `comp.emacs',
  1240. `comp.emacs.xemacs', and possibly some of the language oriented
  1241. newsgroups.  Note that the `cc-mode-victims@python.org' mailing list
  1242. was recently decommissioned.
  1243.  
  1244.